#!/bin/bash

install_item()
{
    echo "start install $1..."
    sudo apt-get -y install "$1"
}

# 安装必要的工具
install_tools()
{
    install_item vim
    install_item git
    install_item zsh
    install_item gcc
    install_item g++
    #install_item python3-pip
    install_item cmake
    install_item openjdk-11-jdk
    install_item curl
    # install_item redis-server
}

install_yarn()
{
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    sudo apt update && sudo apt install yarn
}

# 设置ll的显示时间
set_time()
{
    # todo
    echo "export TIME_STYLE='+%Y-%m-%d %H:%M:%S'"
}

set_oh_my_zsh()
{
    echo "set up oh-my-zsh..."
    sh oh_my_zsh.sh
}

set_vimrc()
{
    echo "set up vimrc..."
    git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
    git clone --depth=1 https://hub.fastgit.org/amix/vimrc.git ~/.vim_runtime
   # sh ~/.vim_runtime/install_awesome_vimrc.sh
    echo "set nu" >> ~/.vim_runtime/vimrcs/basic.vim
}

set_gnome_terminal_theme()
{
    sh one-dark.sh
}

set_fonts()
{
    sudo cp -af ./fonts/* /usr/share/fonts/
    fc-cache -f -v
}

update_ppa()
{
    sudo cp -f huawei_cloud_sources.list /etc/apt/sources.list
    sudo apt-get update
    sudo apt-get -y upgrade
}

download_jetbrains()
{
    wget https://download.jetbrains.com/python/pycharm-community-2020.3.5.tar.gz
    wget https://download.jetbrains.com/idea/ideaIC-2020.3.3.tar.gz
}

download_maven()
{
    wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
}

# 对环境进行设置
set_all()
{
    set_gnome_terminal_theme
    set_vimrc
    set_oh_my_zsh
    set_time
    set_fonts
}

download_anaconda()
{
    wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2020.11-Linux-x86_64.sh
   # sh Anaconda3-2020.11-Linux-x86_64.sh
}

download_vscode()
{
    wget https://code.visualstudio.com/sha/download\?build\=stable\&os\=linux-deb-x64 -O code.deb
    sudo dpkg -i code.deb
}

download_chrome()
{
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
    sudo dpkg -i google-chrome-stable_current_amd64.deb
}

download_sublime()
{
    wget https://download.sublimetext.com/sublime-text_build-3126_amd64.deb
    sudo dpkg -i sublime-text_build-3126_amd64.deb
}

download_ides()
{
    download_sublime
    download_vscode
    download_jetbrains
    download_anaconda
    download_chrome
    download_maven
}

main()
{
    update_ppa
    install_tools
    set_all
    download_ides
}

#main
#set_vimrc
set_fonts
